getApp();
Component({
  properties: {
    is_credit: { value: '0', type: String },
    discountList: { value: [], type: Array },
    drawActiveData: { value: {}, type: Object },
    goodsId: { value: '0', type: String },
    is_no_reason: { value: 0, type: Number },
    return_remark: { value: '', type: String },
    goodsType: { value: {}, type: Object },
    buyData: { type: Object, value: {} },
  },
  observers: {
    'is_credit, discountList, drawActiveData, buyData, goodsType, is_no_reason':
      function (t, e, a, o, n, i) {
        var r = 0,
          s = 0,
          c = 0;
        '0' != t && (r++, c++),
          n &&
            n.hasOwnProperty('type') &&
            'weidou' != n.type &&
            (e.length > 0 && (r++, s++),
            o.today_rank_num && (r++, s++),
            i && (r++, s++),
            a.is_draw && (r++, c++),
            s <= 1 && s === r && (r = 0)),
          this.setData({
            activeHas: r,
            block_act_num: s,
            other_act_num: c,
            today_rank_num: o.today_rank_num || {},
          });
      },
  },
  data: {
    activeHas: 0,
    block_act_num: 0,
    other_act_num: 0,
    showCouponWrap: !1,
    downloadTipsFlag: !1,
  },
  lifetimes: { attached: function () {} },
  methods: {
    toggleCouponWrap: function () {
      this.setData({ showCouponWrap: !this.data.showCouponWrap });
    },
    handleDownoadTips: function () {
      console.log(1),
        this.setData({ downloadTipsFlag: !this.data.downloadTipsFlag });
    },
    _showrr: function () {
      this.triggerEvent('showrr');
    },
    toDraw: function () {
      var t = this;
      if (wx.getStorageSync('accessToken')) {
        var e = this.properties.drawActiveData,
          a = 'activity_id='.concat(e.activity_id);
        wx.navigateTo({
          url: '/pages/webview/webview?route='
            .concat(e.draw_prize_h5_url_min, '&_query=')
            .concat(encodeURIComponent(a)),
        });
      } else
        wx.showModal({
          title: '您还没有登录',
          confirmText: '现在登录',
          cancelText: '不登录',
          content: '如果不登录的话就无法参加抽奖哦~！',
          success: function (e) {
            e.confirm
              ? (console.log('用户点击确定'), t.triggerEvent('showLogin'))
              : e.cancel && console.log('用户点击取消');
          },
        });
    },
  },
});
